package at.spengergasse.web.listener;

import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionAttributeListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class SessionAttributeListener implements HttpSessionAttributeListener {
  private final Log log = LogFactory.getLog(SessionAttributeListener.class);

  public void attributeAdded(HttpSessionBindingEvent event) {
    if (log.isDebugEnabled())
      log.debug(new StringBuilder(event.getSession().getId()).append(
        " - add attribute: ").append(event.getName()).append(" - ").append(
        event.getValue()).toString());
  }

  public void attributeReplaced(HttpSessionBindingEvent event) {
    if (log.isDebugEnabled())
      log.debug(new StringBuilder(event.getSession().getId()).append(
        " - replace attribute: ").append(event.getName()).append(" - ").append(
        event.getValue()).toString());
  }

  public void attributeRemoved(HttpSessionBindingEvent event) {
    if (log.isDebugEnabled())
      log.debug(new StringBuilder(event.getSession().getId()).append(
        " - remove attribute: ").append(event.getName()).append(" - ").append(
        event.getValue()).toString());
  }
}
